

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>插件 &mdash; Singularity container 3.5 documentation</title>
  

  
  
    <link rel="shortcut icon" href="_static/favicon.png"/>
  
  
  

  
  <script type="text/javascript" src="_static/js/modernizr.min.js"></script>
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
        <script src="_static/jquery.js"></script>
        <script src="_static/underscore.js"></script>
        <script src="_static/doctools.js"></script>
        <script src="_static/language_data.js"></script>
        <script src="_static/js/ga.js"></script>
    
    <script type="text/javascript" src="_static/js/theme.js"></script>

    

  
  <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="_static/css/custom.css" type="text/css" />
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="安全选项" href="security_options.html" />
    <link rel="prev" title="OCI Runtime" href="oci_runtime.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="index.html" class="icon icon-home"> Singularity container
          

          
            
            <img src="_static/logo.png" class="logo" alt="Logo"/>
          
          </a>

          
            
            
              <div class="version">
                3.5
              </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul>
<li class="toctree-l1"><a class="reference internal" href="introduction.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="quick_start.html">快速入门</a></li>
<li class="toctree-l1"><a class="reference internal" href="security.html">Singularity安全</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="build_a_container.html">Build容器</a></li>
<li class="toctree-l1"><a class="reference internal" href="definition_files.html">Definition文件</a></li>
<li class="toctree-l1"><a class="reference internal" href="build_env.html">Build环境</a></li>
<li class="toctree-l1"><a class="reference internal" href="singularity_and_docker.html">Singularity和Docker</a></li>
<li class="toctree-l1"><a class="reference internal" href="fakeroot.html">Fakeroot</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="signNverify.html">签名和认证</a></li>
<li class="toctree-l1"><a class="reference internal" href="key_commands.html">Key管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="encryption.html">容器加密</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="endpoint.html">容器仓库</a></li>
<li class="toctree-l1"><a class="reference internal" href="cloud_library.html">Cloud Library</a></li>
</ul>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="bind_paths_and_mounts.html">路径映射</a></li>
<li class="toctree-l1"><a class="reference internal" href="persistent_overlays.html">持久化Overlay</a></li>
<li class="toctree-l1"><a class="reference internal" href="running_services.html">运行服务</a></li>
<li class="toctree-l1"><a class="reference internal" href="environment_and_metadata.html">环境变量和元数据</a></li>
<li class="toctree-l1"><a class="reference internal" href="oci_runtime.html">OCI运行时</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">插件</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#id2">概述</a></li>
<li class="toctree-l2"><a class="reference internal" href="#id3">使用插件</a></li>
<li class="toctree-l2"><a class="reference internal" href="#id4">开发插件</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="security_options.html">安全选项</a></li>
<li class="toctree-l1"><a class="reference internal" href="networking.html">网络选项</a></li>
<li class="toctree-l1"><a class="reference internal" href="cgroups.html">Cgroups</a></li>
<li class="toctree-l1"><a class="reference internal" href="mpi.html">MPI应用</a></li>
<li class="toctree-l1"><a class="reference internal" href="gpu.html">GPU支持</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="contributing.html">Contributing</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="appendix.html">Appendix</a></li>
<li class="toctree-l1"><a class="reference internal" href="cli.html">Command Line Reference</a></li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="index.html">Singularity container</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content style-external-links">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="index.html">Docs</a> &raquo;</li>
        
      <li>插件</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            
              <a href="https://github.com/sylabs/singularity-userdocs/blob/master/plugins.rst" class="fa fa-github"> Edit on GitHub</a>
            
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="plugins">
<span id="id1"></span><h1>插件<a class="headerlink" href="#plugins" title="Permalink to this headline">¶</a></h1>
<div class="section" id="id2">
<h2>概述<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h2>
<p>Singularity插件是一个包，这个包可以被动态的加载到Singularity的运行环境环境中,
使用插件可以做些实验性的，非标准的或者特殊用户需求的功能。
将来，插件将能和Singularity的更多的命令交互。</p>
</div>
<div class="section" id="id3">
<h2>使用插件<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h2>
<p><code class="docutils literal notranslate"><span class="pre">list</span></code> 命令会列出当前已经安装的插件。</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$ singularity plugin list
There are no plugins installed.
</pre></div>
</div>
<p>插件是二进制的文件被打包到一个SIF文件，插件的作者也可以发布插件的源代码，可以使用 <code class="docutils literal notranslate"><span class="pre">compile</span></code> 命令编译生成插件。
下面例子是通过源码编译生成插件 <code class="docutils literal notranslate"><span class="pre">test-plugin</span></code>。</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$ singularity plugin compile examples/plugins/test-plugin/
</pre></div>
</div>
<p>编译完成以后，源代码的路径下降会生成一个SIF文件。</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$ ls examples/plugins/test-plugin/ | grep sif
test-plugin.sif
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p><strong>所有</strong> 的插件必须从Singularity的源码来编译。</p>
</div>
<p>每个插件包含插件的各种信息，比如插件作者，插件版本等。通过 <code class="docutils literal notranslate"><span class="pre">inspect</span></code> 命令查看插件信息。</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$ singularity plugin inspect examples/plugins/test-plugin/test-plugin.sif
Name: sylabs.io/test-plugin
Description: This is a short test plugin for Singularity
Author: Michael Bauer
Version: 0.0.1
</pre></div>
</div>
<p>使用 <code class="docutils literal notranslate"><span class="pre">install</span></code> 命令安装插件，这个命令需要root用户权限。</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$ sudo singularity plugin install examples/plugins/test-plugin/test-plugin.sif
$ singularity plugin list
ENABLED  NAME
    yes  sylabs.io/test-plugin
</pre></div>
</div>
<p>安装成功后，插件会被自动的加载。通过 <code class="docutils literal notranslate"><span class="pre">disable</span></code> 能不启用插件，通过 <code class="docutils literal notranslate"><span class="pre">enable</span></code> 能启用插件。
这些操作也需要root权限。</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$ sudo singularity plugin disable sylabs.io/test-plugin
$ singularity plugin list
ENABLED  NAME
     no  sylabs.io/test-plugin
$ sudo singularity plugin enable sylabs.io/test-plugin
$ singularity plugin list
ENABLED  NAME
    yes  sylabs.io/test-plugin
</pre></div>
</div>
<p>最后，我们也可以使用 <code class="docutils literal notranslate"><span class="pre">uninstall</span></code> 命令卸载插件, 这个操作也需要root权限。</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$ sudo singularity plugin uninstall sylabs.io/test-plugin
Uninstalled plugin &quot;sylabs.io/test-plugin&quot;.
$ singularity plugin list
There are no plugins installed.
</pre></div>
</div>
</div>
<div class="section" id="id4">
<h2>开发插件<a class="headerlink" href="#id4" title="Permalink to this headline">¶</a></h2>
<p>对开发插件感兴趣的开发者可以先查看文档 <a class="reference external" href="https://godoc.org/github.com/sylabs/singularity/pkg/plugin">Go documentation</a>。 更进一步, 可以读一些 <a class="reference external" href="https://github.com/sylabs/singularity/tree/master/examples/plugins/test-plugin">例子代码</a>，
更多关于插件开发的文档还在开发中，将在以后的版本中发布。</p>
</div>
</div>


           </div>
           
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="security_options.html" class="btn btn-neutral float-right" title="安全选项" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="oci_runtime.html" class="btn btn-neutral float-left" title="OCI Runtime" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2017-2019, Sylabs Inc

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>